home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / binaries / Windows / JavaIDL-EA-win32.EXE / JavaIDL / examples / portfolio / PortfolioClient.java < prev    next >
Encoding:
Java Source  |  1997-03-05  |  1.4 KB  |  58 lines

  1. /**
  2.  * This class is the implementation of Portfolio Client
  3.  * @author Rahul
  4.  */
  5.  
  6.  
  7. import java.io.*;
  8.  
  9. import org.omg.CORBA.*;
  10. import com.sun.CORBA.iiop.*;
  11.  
  12. // This is the directory where the idl-to-java compiler put stuff
  13. import PortfolioManager.* ;
  14.  
  15. public 
  16. class PortfolioClient {
  17.   /** ORB
  18.   **/
  19.   public 
  20.   static com.sun.CORBA.iiop.ORB theOrb_;
  21.  
  22.   public 
  23.   static PortfolioManager.Portfolio ref_;
  24.  
  25.   public
  26.   static void main(String args[]) {
  27.     try {
  28.       // Get an orb object
  29.       String[] paramList = new String[2];
  30.       paramList[0] = "-ORBHost";
  31.       paramList[1] = java.net.InetAddress.getLocalHost().getHostName();
  32.       theOrb_ = new com.sun.CORBA.iiop.ORB(paramList, null);
  33.  
  34.       // Read IOR from file
  35.       InputStream inf = 
  36.            new FileInputStream(System.getProperty("user.home") + 
  37.                                System.getProperty("file.separator") + 
  38.                                                   "Portfolio.ior") ;
  39.  
  40.       DataInputStream in = new DataInputStream(inf) ;
  41.       String ior2 = in.readLine();
  42.  
  43.       // Get objref
  44.       org.omg.CORBA.Object obj = theOrb_.string_to_object(ior2) ;
  45.       ref_ = PortfolioManager.PortfolioHelper.narrow(obj);
  46.  
  47.       ref_.addStock("SUNW", (short)100, 33.50);
  48.       System.out.println("Report: " + ref_.report());
  49.  
  50.     }
  51.     catch (Exception ex) {
  52.       ex.printStackTrace();
  53.       System.out.println("Portfolio Client: Exception-> " + ex) ;
  54.     }
  55.   }
  56.  
  57. }
  58.